{template 'public/header'}
{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/zh_tcwq/template/public/ygcsslist.css">
<style type="text/css">
  .yg5_key>div{float: left;line-height: 34px;}
  .fxfont3{text-align: left;}
  .store_list_img{width: 80px;height:80px;}
  .yg5_tabel{border: none;outline: none;text-align: center;}
  .yg5_tr2>td{padding: 10px 5px;border-bottom: 1px solid #e5e5e5;}
  .yg5_tr1>td{
    padding: 10px 5px;
    border-bottom: 1px solid #e5e5e5;
  }
  .yg5_btn{background-color: #EEEEEE;color: #333;border: 1px solid #E4E4E4;border-radius: 6px;width: 100px;height: 34px;}
  .check_img{width: 45px;height: 45px;}
  .fxmain{background-color: white;}
  .panel{box-shadow: 0 0px 0px;}
  .fxrow{border-bottom: 1px solid #e5e5e5;padding-bottom: 10px;}
  .fxuserimg{width: 30px;height: 30px;border-radius: 50%;border:1px solid #ccc;}
  .fxuserimg2{width: 30px;height: 30px;border-radius: 50%;border:1px solid #ccc;margin-right: 10px;}
  .fxfont1{color: #eb6060;}
  .fxfont2{color: #ffc000;}
  .recharge_info{display: -webkit-flex;display: -webkit-box;display: -ms-flexbox;display: flex;justify-content: space-around;margin-bottom: 10px;}
  .recharge_info>div{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;border:1px solid #efefef;margin:0 10px;padding: 10px 22px;line-height: 25px;color: #333;width: 310px;height: 97px;}
  .tabs-container{border-bottom: 1px solid #e5e5e5;padding: 10px;}
  .fxnum{line-height: 30px;font-size: 14px;}
</style>
<ul class="nav nav-tabs">
  <span class="ygxian"></span>
  <div class="ygdangq">当前位置:</div>
  <li class="active"><a href="javascript:void(0);">合伙人管理</a></li>
</ul>
<div class="main fxmain" style="padding: 1px 30px;">
  <div class="row fxrow">
    <div class="col-lg-12">
      <form action="" method="get" class="col-md-6">
        <input type="hidden" name="c" value="site" />
        <input type="hidden" name="a" value="entry" />
        <input type="hidden" name="m" value="zh_tcwq" />
        <input type="hidden" name="do" value="fxlist" />
        <div class="input-group" style="width: 300px;margin-top: 20px;">
          <input type="text" name="keywords" class="form-control" value="{$_GPC['keywords']}" placeholder="请输入联系人">
          <span class="input-group-btn">
            <input type="submit" class="btn btn-default" name="submit" value="查找"/>
          </span>
        </div>
        <input type="hidden" name="token" value="{$_W['token']}"/>
      </form>
      <form action="" method="get" class="col-md-6">
                   <input type="hidden" name="c" value="site" />
                   <input type="hidden" name="a" value="entry" />
                   <input type="hidden" name="m" value="zh_tcwq" />
                   <input type="hidden" name="do" value="fxlist" />
            <div class="input-group" style="width: 300px;margin-top: 20px;">
                
                 <input type="submit" class="btn btn-sm ordersucess" name="export_submit" value="导出"/>
            </div><!-- /input-group -->
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>
    </div><!-- /.col-lg-6 -->

  </div>  
  <div class="main" style="margin: 5px 0px;">
    <div class="panel">
      <div class="panel-body" style="padding: 0px 30px;">
        <div class="row">
          <table class="yg5_tabel col-md-12">
            <tr class="yg5_tr1">

              <td class="fxfont3">粉丝</td>
              <td>手机号码</td>
              <td>级别</td>
              <td>累计佣金<br/>打款佣金</td>
              <td>上级分销商</td>
              <td>下级分销商</td>
              <td>申请时间</td>
              <td>审核状态</td>
              <td>操作</td>
            </tr>
            {loop $list $key $item}
            {php $cg = pdo_fetch("select sum(tx_cost) as tx_cost from " . tablename("zhtc_commission_withdrawal")." WHERE  state=2 and user_id=".$item['user_id']);}
            {php $lei = pdo_fetch("select sum(money) as tx_cost from " . tablename("zhtc_earnings")." WHERE  user_id=".$item['user_id']);}

            <?php  $sql="select a.* ,b.name,b.img from " . tablename("zhtc_fxuser") . " a"  . " left join " . tablename("zhtc_user") . " b on b.id=a.fx_user   WHERE a.user_id=:user_id order by id DESC";
            $res=pdo_fetchall($sql,array(':user_id'=>$item['user_id']));
            $res2=array();
            for($i=0;$i<count($res);$i++){
            $sql2="select a.* ,b.name,b.img from " . tablename("zhtc_fxuser") . " a"  . " left join " . tablename("zhtc_user") . " b on b.id=a.fx_user   WHERE a.user_id=:user_id order by id DESC";
            $res3=pdo_fetchall($sql2,array(':user_id'=>$res[$i]['fx_user']));
            $res2[]=$res3;

          }

          $res4=array();
          for($k=0;$k<count($res2);$k++){
          for($j=0;$j<count($res2[$k]);$j++){
          $res4[]=$res2[$k][$j]; 
        }

      }
      ?>
      <tr class="yg5_tr2">
        <td class="fxfont3">
          <img class="fxuserimg" src="{$item['img']}">
          {$item['user_name']}</td>
          <td class="store_td1">{$item['user_tel']}</td>
          <td class="store_td1">{$item['level_name']}</td>
          <td>
            <span class="fxfont1">{if $lei['tx_cost']}{$lei['tx_cost']}{else}0.00{/if}</span><br/>
            <span class="fxfont2">{if $cg['tx_cost']}{$cg['tx_cost']}{else}0.00{/if}</span>
          </td>
          {php $sj=pdo_get('zhtc_fxuser',array('fx_user'=>$item['user_id']));}
          {php $sj2=pdo_get('zhtc_distribution',array('user_id'=>$sj['user_id']));}
          <td class="store_td1">{if $sj['user_id']}{$sj2['user_name']}{else}总店{/if}</td>
          <td><a href="{php echo $this->createWebUrl('yj',array('user_id'=>$item['user_id']))}">{php echo count($res)+count($res4)}</a></td>
          <td>{php echo date("Y-m-d H:i:s",$item['time'])}</td>


          {if $item['state']==1}
          <td>
            <span class="label storered">待审核</span>
          </td>
          {elseif $item['state']==2}
          <td>
            <span class="label storeblue">已通过</span>
          </td>
          {elseif $item['state']==3}
          <td>
           <span class="label storegrey">已拒绝</span>
          </td>
          {/if}  
          <td>
          {if $item['state']==1}
          <a class="btn ygyouhui2 btn-xs" href="{php echo $this->createWebUrl('fxlist',array('id'=>$item['id'],'op'=>'adopt'))}" title="通过">通过</a>
          <a class="btn storegrey2 btn-xs" href="{php echo $this->createWebUrl('fxlist', array('id' => $item['id'],'op'=>'reject'))}" title="拒绝">拒绝</a>
          {/if}
          {if $item['state']==2}
          <!-- <a href="javascript:void(0);" data-toggle="modal" data-target="#myModalb{$item['user_id']}"><span class="btn btn-xs ygyouhui2">充值佣金</span> </a> -->
          <a href="{php echo $this->createWebUrl('fxinfo', array('id' => $item['id']))}" class="storespan btn btn-xs">
              <span class="fa fa-pencil"></span>
              <span class="bianji">编辑
                  <span class="arrowdown"></span>
              </span>
          </a>
          <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModalb{$item['user_id']}">
            <span class="fa fa-money" style="margin:0px;"></span>
            <span class="bianji" style="left:-70%;">充值佣金
              <span class="arrowdown"></span>
            </span>
          </a>
          {/if}

          <a href="{php echo $this->createWebUrl('fxlist', array('id' => $item['id'],'op'=>'delete'))}" class="storespan btn btn-xs" onclick="return confirm('确认删除吗？');return false;" title="删除">
            <span class="fa fa-trash-o"></span>
            <span class="bianji">删除
              <span class="arrowdown"></span>
            </span>
          </a>
          <!-- <a class="btn btn-danger btn-xs" href="{php echo $this->createWebUrl('fxlist', array('id' => $item['id'],'op'=>'delete'))}" onclick="return confirm('确认删除吗？');return false;" title="删除">删</a> -->

        </td>

      </td>

    </tr>
    <div class="modal fade" id="myModalb{$item['user_id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <form action="" method="post" enctype="multipart/form-data" class="">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title" id="myModalLabel">会员充值</h4>
            </div>
            <div class="modal-body form-horizontal form-validate">
              <div class="recharge_info">
                <div>
                  <label class="pull-left" style="margin-right: 25px">粉丝</label>
                  <div class="pull-left">
                    <img class="fxuserimg2" src="{$item['img']}">{$item['user_name']}
                  </div>
                </div>
                <div>
                  <label class="pull-left" style="margin-right: 25px">会员信息</label>
                  <div class="pull-left">
                    ID:{$item['user_id']}<br/>姓名：{$item['user_name']}<br/>手机号：{$item['user_tel']}
                  </div>
                </div>                                        
                <!-- <input type="number" name="reply" class="accout_inp col-md-9" placeholder="请输入金额"> -->
              </div>
              <div class="tabs-container">
                充值余额
              </div>
              <div class="form-group"></div>
              <div class="form-group">
                <label class="col-sm-2 control-label">当前余额</label>
                <div class="col-sm-10">
                  <span class="fxnum">{$item['commission']}</span>
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label">充值数目</label>
                <div class="col-md-5">
                 <input type="number" name="reply" class="form-control accout_inp" placeholder="请输入金额">
                 <!-- <input type="text" name="dada_key" value="{$info['dada_key']}" id="web_name" class="form-control" /> -->
                 <!-- <div class="ygmargin">*请去http://newopen.imdada.cn申请</div> -->
               </div>
             </div>
           </div>
           <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            <input type="submit" name="submit2" class="btn btn-info" value="确定">
            <input type="hidden" name="token" value="{$_W['token']}"/>
            <input type="hidden" name="id2" value="{$item['user_id']}"/>
          </div>
        </div>
      </form>
    </div>
  </div>
  {/loop}
  {if empty($list)}
  <tr class="yg5_tr2">
    <td colspan="9">
      暂无分销商
    </td>
  </tr> 
  {/if}        



</table>

</div>

</div>

</div>
</div>
</div>
<div class="text-right we7-margin-top">

 {$pager}

</div>
<script type="text/javascript">
  $(function(){
        // $("#frame-9").addClass("in");
        $("#frame-19").show();
        $("#yframe-19").addClass("wyactive");
      })
    </script>{template 'common/footer'}